Complete Module Reference Guide - ABAP Aggregate Demand Report
← Back to Overview | ← Previous: Period Utilities
Program Structure Overview
This reference guide provides a complete module-by-module breakdown of the YMTIR_R102_AGGR_DEMAND_REP program with exact line numbers, dependencies, and flow relationships.
Module Classification Matrix
| Tier | Module Name | Line Range | Purpose | Dependencies |
|---|---|---|---|---|
| Tier 1: Core Processing | ||||
| 1 | select_data | 1326-1610 | Data selection engine | → get_data_marc, check_authority |
| 1 | process_data | 1664-2108 | Demand aggregation engine | ← select_data → appotion_quantity |
| 1 | build_output_table_new | 6566-7060 | Output table builder | ← process_data → ALV display |
| 1 | alv_report | 3799-3802 | Report display controller | ← fill_field_catalog, build_output_table_new |
| Tier 2: Period Management | ||||
| 2 | calulate_acct_periods | 4885-5050 | Accounting period calculation | → build_acct_columns |
| 2 | build_acct_columns | 5051-5254 | Accounting column builder | ← calulate_acct_periods |
| 2 | calulate_stnd_periods | 5255-5419 | Calendar period calculation | → build_stnd_columns |
| 2 | build_stnd_columns | 5420-5617 | Calendar column builder | ← calulate_stnd_periods |
| 2 | build_col_date_index | 2109-2207 | Weekly period builder | → Used by main processing |
| Tier 3: UI and Interaction | ||||
| 3 | display_alv | 1162-1227 | ALV container module | → lcl_event_receiver |
| 3 | lcl_event_receiver | 1068-1137 | Event handling class | ← display_alv |
| 3 | user_command_0100 | 1240-1255 | User command handler | → Various forms |
| 3 | user_command_0200 | 1228-1239 | Popup command handler | → display_list |
| 3 | display_list | 3849-3963 | Drill-down popup | ← Event handlers |
| Tier 4: Utility and Support | ||||
| 4 | fill_field_catalog | 3471-3798 | Field catalog builder | → ALV display |
| 4 | get_data_marc | 1616-1663 | Material master data | ← select_data |
| 4 | appotion_quantity | 4359-4396 | Stock apportionment | ← process_data |
| 4 | download_file | 3964-4263 | File export functionality | ← User commands |
| 4 | check_authority | 1256-1284 | Authorization validation | ← Selection screen |
| 4 | initialize_data | 1285-1325 | Data initialization | ← Program start |
Complete Processing Flow with Line References
Critical Data Structures and Their Lifecycle
Material Data Flow
Time Period Data Flow
Module Interaction Matrix
| From Module | To Module | Data Passed | Line Reference |
|---|---|---|---|
select_data | get_data_marc | Selection criteria | 1360-1363, 1480-1483 |
process_data | appotion_quantity | Material, plant, vendor, stock | 1761-1764 |
build_output_table_new | fill_field_catalog | Column requirements | Called at line 1045 |
lcl_event_receiver | display_list | Row data for drill-down | 1076 |
| All period forms | build_output_table_new | Time bucket definitions | Used in loops 6857-6891 |
Key Business Rules Implementation
Rule 1: Vendor vs Material Mode Processing
" Lines 1346-1539 in select_data
IF r_vendor EQ c_x.
" Vendor mode: Filter by specific vendors first
" Then get materials for those vendors
ELSEIF r_mat EQ c_x.
" Material mode: Get materials first
" Vendor filtering happens later
ENDIF.
Rule 2: Report Type Filtering
" Lines 1776-1855 in process_data
IF p_pd = c_x . " Production Demand
" Keep: Production orders, planned orders
" Remove: Purchase orders, stock transfers
ELSEIF p_co = c_x. " Committed Orders
" Keep: Purchase requisitions, purchase orders
" Remove: Production orders
ELSE. " Sales/Libre
" Keep: Sales orders, deliveries
" Remove: Internal production orders
ENDIF.
Rule 3: Safety Stock Handling
" Lines 6631-6634 in build_output_table_new
IF p_sftstk <> 'X' AND lw_matfcast-extra = 'Safety Stock'.
CONTINUE. " Exclude safety stock if not selected
ENDIF.
Rule 4: Follow-up Material Logic
" Lines 1407-1437 in select_data
" If Material A has follow-up Material B:
" - Include both A (with followup=B) and B (with its own followup)
" - Prevent duplicate entries of Material B
" - Handle multi-level follow-up chains (A→B→C)
Performance Critical Sections
| Section | Line Range | Performance Impact | Optimization Used |
|---|---|---|---|
| Material Selection | 1366-1398 | High - Large tables | FOR ALL ENTRIES pattern |
| MRP API Calls | 1735-1748 | Very High - External API | Called once per material |
| Output Table Building | 6869-6891 | High - Nested loops | BINARY SEARCH, FROM clause |
| Field Catalog Building | 3471-3798 | Medium - Many columns | Static definitions where possible |
| Period Calculations | 4885-5617 | Low-Medium | SAP standard functions |
Error Handling Strategies
Data Selection Errors
" Line 1749 in process_data
CHECK sy-subrc = 0. " Skip materials with MRP API errors
Period Calculation Errors
" Lines 4908-4911 in calulate_acct_periods
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Validation Errors
" Lines 1350-1351 in select_data
IF s_lifnr[] IS INITIAL.
MESSAGE i000 WITH 'Vendor is mandatory'(040).
LEAVE LIST-PROCESSING.
ENDIF.
Memory and Resource Management
Internal Table Sizing
" Efficient internal table declarations
DATA: t_matfcast TYPE type_t_matfcast INITIAL SIZE 0,
t_materials TYPE STANDARD TABLE OF ty_materials INITIAL SIZE 0.
Object Lifecycle
" Lines 1162-1227: ALV objects created once and reused
IF w_container IS INITIAL.
CREATE OBJECT w_container.
CREATE OBJECT w_grid.
" Objects persist for program lifetime
ENDIF.
Integration Points Summary
Incoming Interfaces
- Selection Screen: User parameters and ranges
- SAP Standard Tables: MARC, EORD, LFA1, T001W, etc.
- SAP Standard Functions: MRP API, Period functions, Date functions
Outgoing Interfaces
- ALV Framework: For report display
- File System: For data export
- User Interface: Screens and popups
Internal Integration
- Global Variables: Shared across all forms
- Internal Tables: Data passed between processing stages
- Function Modules: Custom utility functions (YMTIR_*)
Module Dependencies Visualization
This comprehensive reference provides line-exact navigation through the entire program structure, enabling both beginners to understand the flow and experienced developers to quickly locate specific functionality.
Navigation
← Back to Overview | ← Previous: Period Utilities